package com.example.demo.utils;

import io.swagger.annotations.ApiModelProperty;
import lombok.Getter;
import lombok.Setter;

/**
 * TODO
 * 返回对象实体类 封装返回结果(不包含数据)
 * @author caiyonglan
 * @email 627064518@qq.com
 * @date 2020/12/2 15:05
 */
@Getter
@Setter
public class Response {

    @ApiModelProperty(value = "响应码", example = "200")
    private Integer code;

    @ApiModelProperty(value = "响应消息", example = "success")
    private String msg;

    public static Response success(ExceptionMsg exceptionMsg) {
        Response response = new Response();
        response.setCode(exceptionMsg.getCode());
        response.setMsg(exceptionMsg.getMsg());
        return response;
    }

    public static Response error(ExceptionMsg exceptionMsg) {
        Response response = new Response();
        response.setCode(exceptionMsg.getCode());
        response.setMsg(exceptionMsg.getMsg());
        return response;
    }
}
